package com.signway.ffmpeg;

import android.graphics.Bitmap;
import android.media.MediaCodec;
import android.media.MediaFormat;

import java.nio.ByteBuffer;

public class FFmpeg {
    // Used to load the 'ffmpeg' library on application startup.
    static {
        System.loadLibrary("ffmpeg");
    }

    public boolean createEncoder(MediaFormat mMediaFormat) {
        int width = mMediaFormat.getInteger(MediaFormat.KEY_WIDTH);
        int height = mMediaFormat.getInteger(MediaFormat.KEY_HEIGHT);
        int fps = mMediaFormat.getInteger(MediaFormat.KEY_FRAME_RATE);
//        int bitrate = mMediaFormat.getInteger(MediaFormat.KEY_BIT_RATE);
        return nativeCreateEncoder(width, height, fps, 3840*2160);
    }

    /**
     * A native method that is implemented by the 'ffmpeg' native library,
     * which is packaged with this application.
     */
    public native String stringFromJNI();

    /**
     * Rotating media file
     * @param src scr file name
     * @param dst dst file name
     * @param degree rotating degree
     * @return
     */
    public native boolean rotatingMediaFile(String src, String dst, int degree);

    public native boolean nativeCreateEncoder(int width, int height, int fps, int bitrate);
    public native boolean nativeCreateDecoder(String file);
    public native boolean onOutputBufferAvailable(ByteBuffer byteBuffer, MediaCodec.BufferInfo bufferInfo);
}